package my2Cents;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;

import javax.swing.JButton;
import javax.swing.JScrollPane;

import my2Cents.tools.AbstractPhysTool;

public class ToolList {
	private String category;
	private JComponentList toolList;
	private JScrollPane toolSP;
	private KeyAdapter closeage;
	
	public ToolList(String category) {
		this.category = category;
		toolList = new JComponentList();
		toolList.setLayout(null);
		toolSP = new JScrollPane(toolList);
		toolSP.setHorizontalScrollBarPolicy(
				JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		toolSP.setVerticalScrollBarPolicy(
				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	}
	
	public String getCategory() {
		return category;
	}
	
	public JComponentList getButtonList() {
		return toolList;
	}
	
	public JScrollPane getScrollPane() {
		return toolSP;
	}
	
	public JButton addTool(final AbstractPhysTool tool) {
		JButton b = new JButton();
		b.setSize(10,20);
		b.setText(tool.getName());
		b.setVisible(true);
		b.addKeyListener(closeage);
		toolList.add(b);
		return b;
	}

	public void setKeyAdapter(KeyAdapter ka) {
		this.closeage = ka;
	}

}
